<?php
class Forbidden_ip_model extends CI_Model {

	function __construct()
    {
        parent::__construct();
    }
	/**
	 * 新增一张点卡，code随机
	 */
	public function add($ip) {   
		
		$sql = "insert into forbidden_ips  set ip = " . $this->db->escape($ip) ;
		return $this->db->query($sql);
	}
	
	public function find_all() {
		$result = $this->db->get('forbidden_ips')->result_array();
		return $result;
	}
	
	public function delete($id) {
		$this->db->delete('forbidden_ips', array('id' => $id)); 
	}
	
	public function find_all_ips() {
		$result = $this->db->get('forbidden_ips')->result_array();
		$return_array = array();
		foreach ($result as $r) {
			$return_array[] = $r['ip'];
		}
		return $return_array;
	}
	
}